"""
@author: wg
@file: homework11_24_1.py
@time: 2023/11/28 20:51
"""
# 用户密码密码复杂度验证
strs = input("请输入用户密码\n")
def passwd(strs):
    count1 = count2 = count3 = count4 = 0     # 字符种类统计
    for i in strs:
        if i.isupper():
            count1 += 1
        elif i.islower():
            count2 += 1
        elif i.isdigit():
            count3 += 1
        else:
            count4 += 1
    ikun = 0
    for i in range(len(strs)-5):  # 统计长度等于3的字串重复的数量
        j = i+3
        while j < len(strs)-2:
            if strs[i] == strs[j]:
                if strs[i+1] == strs[j+1]:
                    if strs[i+2] == strs[j+2]:
                        ikun += 1
            j += 1
    score = 2
    if len(strs) > 8:
        score += 1
    else:
        print("长度小于8")
    if (count1 > 0)+(count2 > 0)+(count3 > 0)+(count4 > 0) >= 3:
        score += 1
    else:
        print("密码没有由3种以上字符组成")
    if ikun == 0:
        score += 1
    else:
        print("密码有长度超过或等于3的字串重复")
    print("评分等级为：", score)
    return score

passwd(strs)
